const fs = require('fs')
const path = require('path')

const loadRoutes = (router) => {
  const routesDir = path.join(__dirname, '')
  fs.readdirSync(routesDir).forEach(file => {
    if (file.endsWith('.js') && file !== 'loadRoutes.js') {
      const route = require(path.join(routesDir, file))
      router.use(route.routes())
    }
  })
}

module.exports = loadRoutes